import request from '../utils/request-new'

export const getTrainTaskData = () => {
  return request({
    url: '/project/task/getData',
    method: 'GET'
  })
}

export const getTrainProjectList = (data: {
  pageNum?: number,
  pageSize?: number,
  taskName?: string
}) => {
  return request({
    url: '/project/page',
    method: 'GET',
    data
  })
}

// ALL-全部，INCOMPLETE-未完成，COMPLETE-已完成，REJECT-被驳回
type Type = {
  [key in number]: string
}
const typeEnum: Type = {
  1: 'ALL',
  2: 'INCOMPLETE',
  3: 'COMPLETE',
  4: 'REJECT'
}

export const getTrainTaskList = (data: {
  projectId: number,
  type: number
}) => {
  return request({
    url: '/project/task/list',
    method: 'GET',
    data: {
      projectId: data.projectId,
      type: typeEnum[data.type]
    }
  })
}

export const getTrainTask = (taskId: number) => {
  return request({
    url: `/project/task/${taskId}`,
    method: 'GET'
  })
}

export interface ITrainTask {
  /**
   * 任务Id
   */
  id: number;
  /**
   * 项目Id
   */
  projectId: number;
  /**
   * 评分标准列表
   */
  scoreRuleList: ScoreRuleList[];
  [property: string]: any;
}

export interface ScoreRuleList {
  /**
   * 评分标准Id
   */
  id: number;
  /**
   * 评分标准名称
   */
  name: string;
  /**
   * 评分分数
   */
  score: number;
  [property: string]: any;
}


export const trainTask = (data: ITrainTask) => {
  return request({
    url: `/project/task/train`,
    method: 'POST',
    data
  })
}

export interface IReviewTask {
  /**
   * 任务Id
   */
  id: number;
  /**
   * 评审意见
   */
  reviewRemark?: null | string;
  /**
   * 状态，2-审核通过，3-驳回
   */
  status: string;
  [property: string]: any;
}

export const reviewTask =  (data: IReviewTask) => {
  return request({
    url: '/project/task/review',
    method: 'POST',
    data
  })
}
